package com.admin.monmon.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
 * Knife4j其实是对swagger2的二次封装而已
 *
 * @author caixiaofeng
 * @version 1.0
 * @Description: <<>>
 * @company 个人学习
 * @create 2021-02-02 17:42*/

@Configuration
@EnableSwagger2
public class Knife4jConfiguration {
    @Bean
    public Docket docket() {
        //联系人
        Contact contact = new Contact(
                //联系人
                "caixiaofeng",
                //网址
                "http://localhost:8080/swagger-ui.html#/",
                //邮箱
                "1941338475@qq.com");

        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("标题")
                        .description("描述信息")
                        .termsOfServiceUrl("https://www.apache.org")
                        .contact(contact)
                        .license("Apache 2.0")
                        .version("1.0")
                        .build())
                //是否开启api文档
                .enable(true)
                .groupName("系统模块1.0版本")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.admin.system.controller"))
                .paths(PathSelectors.any())
                .build();
    }
}
